package com.xxxx.paipaicars.common;

import lombok.Data;

/**
 * 这是一个返回值标准模型
 * Created by frank on 2022/10/28.
 */
@SuppressWarnings("all")
@Data
public class Response<T> {
    /**
     * 状态码
     */
    private int code;

    /**
     * 消息内容
     */
    private String msg;

    /**
     * 具体的返回值
     */
    private T t;


    public static Response badResquest() {
        Response<Object> response = new Response<>();
        response.setCode(400);
        response.setMsg("客户端参数异常");
        response.setT(null);
        return response;
    }
    public static Response badResquest(String msg) {
        Response<Object> response = new Response<>();
        response.setCode(400);
        response.setMsg(msg);
        response.setT(null);
        return response;
    }


    public static Response success() {
        Response<Object> response = new Response<>();
        response.setCode(200);
        response.setMsg("调用成功");
        response.setT(null);
        return response;
    }

    public static Response success(String msg) {
        Response<Object> response = new Response<>();
        response.setCode(200);
        response.setMsg(msg);
        response.setT(null);
        return response;
    }

    public static <T> Response success(T t) {
        Response<Object> response = new Response<>();
        response.setCode(200);
        response.setMsg("调用成功");
        response.setT(t);
        return response;
    }

    public static <T> Response success(T t,String msg) {
        Response<Object> response = new Response<>();
        response.setCode(200);
        response.setMsg(msg);
        response.setT(t);
        return response;
    }
    public static <T> Response fail(T t,String msg) {
        Response<Object> response = new Response<>();
        response.setCode(500);
        response.setMsg(msg);
        response.setT(t);
        return response;
    }


}
